home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / ASTRONOM / H139.ZIP / UI101.ZIP / IO / UI / UI.DOC < prev    next >
Text File  |  1991-11-04  |  45KB  |  1,452 lines

  1.  
  2.  
  3.     The BYWATER Graphical USER INTERFACE
  4.  
  5.     Copyright (c) 1991, Ted A. Campbell
  6.  
  7.             Bywater Software
  8.             P. O. Box 4023 
  9.             Duke Station 
  10.             Durham, NC  27706
  11.  
  12.             email: tcamp@uncecs.edu
  13.  
  14.     Copyright and Permissions Information:
  15.  
  16.     All U.S. and international copyrights are claimed by the
  17.     author. The author grants permission to use this code
  18.     and software based on it under the following conditions:
  19.     (a) in general, the code and software based upon it may be 
  20.     used by individuals and by non-profit organizations; (b) it
  21.     may also be utilized by governmental agencies in any country,
  22.     with the exception of military agencies; (c) the code and/or
  23.     software based upon it may not be sold for a profit without
  24.     an explicit and specific permission from the author, except
  25.     that a minimal fee may be charged for media on which it is
  26.     copied, and for copying and handling; (d) the code must be 
  27.     distributed in the form in which it has been released by the
  28.     author; and (e) the code and software based upon it may not 
  29.     be used for illegal activities. 
  30.  
  31. The Bywater Graphical User Interface offers a user interface 
  32. employing various types of graphical windows, keyboard, mouse,
  33. and icons. It serves as the basis for the Bywater Space Flight 
  34. Simulator and for other projects underway at Bywater.  The
  35. system is currently implemented on the IBM PC and compatibles
  36. utilizing the Microsoft QuickC compiler, on the AT&T Unix PC
  37. (PC 7300), and on DecStation Unix Workstations utilizing the 
  38. X Windows system.  
  39.  
  40. The system builds on five components:
  41.  
  42.     bw    the error handling system
  43.     gr    the graphics and mouse system
  44.     kb    the keyboard system
  45.     dr    the directory system
  46.     tw    the text window system, 
  47.  
  48. and from these is built
  49.  
  50.     ui    the graphical user interface itself.
  51.  
  52.  
  53.  
  54. REFERENCE FOR GR (GRAPHICS) SYSTEM:
  55. ----------------------------------
  56.  
  57. /****************************************************************
  58.  
  59.     colors
  60.  
  61. ****************************************************************/
  62.  
  63. #define BLACK           0
  64. #define WHITE           1
  65. #define LIGHT_RED       2
  66. #define LIGHT_GREEN     3
  67. #define LIGHT_BLUE      4
  68. #define LIGHT_YELLOW    5
  69. #define LIGHT_CYAN      6
  70. #define LIGHT_MAGENTA   7
  71. #define DARK_RED        10
  72. #define DARK_GREEN      11
  73. #define DARK_BLUE       12
  74. #define DARK_YELLOW     13
  75. #define DARK_CYAN       14
  76. #define DARK_MAGENTA    15
  77.  
  78. /****************************************************************
  79.  
  80.     fill (and line) styles
  81.  
  82. ****************************************************************/
  83.  
  84. #define HOLLOW          0        /* Hollow fill -- draw perimeter */
  85. #define SOLID           1
  86. #define GRID            2
  87. #define HATCH           3
  88.  
  89. /****************************************************************
  90.  
  91.     input modes
  92.  
  93. ****************************************************************/
  94.  
  95. #define    STATUS    0
  96. #define    WAIT    1
  97. #define    SAMPLE    2
  98. #define HIDE    3
  99. #define SHOW    4
  100. #define POSITION        5
  101.  
  102. /****************************************************************
  103.  
  104.     screens
  105.  
  106. ****************************************************************/
  107.  
  108. #define GR_PRIMARY    0    /* primary drawing screen */
  109. #define GR_HIDDEN    1    /* secondary or hidden drawing screen */
  110.  
  111. /****************************************************************
  112.  
  113.     fonts
  114.  
  115. ****************************************************************/
  116.  
  117. #define F_DEFAULT       0
  118. #define F_ROMAN         1
  119. #define F_GOTHIC        2
  120. #define F_ITALIC        3
  121.  
  122. /****************************************************************
  123.  
  124.     gr_window structure
  125.  
  126. ****************************************************************/
  127.  
  128. struct gr_window
  129.     {
  130.     int initialized;        /* Boolean:  successfully initialized?  */
  131.     int xmax;               /* Maximum number of pixels, x axis     */
  132.     int ymax;               /* Maximum number of pixels, y axis     */
  133.     int font;        /* Current font style             */
  134.     int fxsize;             /* Font size in pixels, x axis          */
  135.     int fysize;             /* Font size in pixels, y axis          */
  136.     int clipping;           /* Boolean:  is cliiping in use?        */
  137.     int cl_x1;              /* Left of clip window                  */
  138.     int cl_y1;              /* Bottom of clip window                */
  139.     int cl_x2;              /* Right of clip window                 */
  140.     int cl_y2;              /* Top of clip window                   */
  141.     };
  142.  
  143.     COORDINATE SYSTEM. The gr interface presupposes throughout
  144.     a Cartesian coordinate system in which pixels on the vertical
  145.     axis (the y axis) are numbered beginning with 0 from the
  146.     bottom up, and pixels on the horizontal axis (the x axis)
  147.     are numbered beginning with 0 from the ;eft to the right.
  148.     The numbering of the y axis may seem counterintuitive,
  149.     since in many systems pixels are numbered vertically from
  150.     the top to the bottom.
  151.  
  152. /****************************************************************
  153.  
  154.    gr_init()
  155.  
  156.    This function should initialize the entire graphics and mouse
  157.    subsystem. The argument "grwindow" is a pointer to a gr_window
  158.    structure which should be filled in by the function. The
  159.    argument "font_path" is a pointer to a character string
  160.    giving the name of a path where the function should look
  161.    for font and other data files. The function should return
  162.    BW_ERROR upon any error and TRUE upon a successful setting
  163.    of the graphics subsystem.
  164.  
  165. ****************************************************************/
  166.  
  167. gr_init( grwindow, font_path )
  168.    struct gr_window *grwindow;
  169.    char * font_path;
  170.    
  171.  
  172. /****************************************************************
  173.  
  174.    gr_deinit()
  175.  
  176.    This function should deinitialize the entire graphics subsystem.
  177.  
  178. ****************************************************************/
  179.  
  180. gr_deinit()
  181.    
  182.  
  183. /****************************************************************
  184.  
  185.    gr_cls()
  186.  
  187.    This function should clear the entire screen area.
  188.  
  189.    The argument "screen" is an integer denoted either the
  190.    visible screen (defined as GR_PRIMARY) or a hidden buffer
  191.    to which graphics output can be written (defined as
  192.    GR_HIDDEN).
  193.  
  194. ****************************************************************/
  195.  
  196. gr_cls( screen )
  197.    int screen;
  198.    
  199.  
  200.  
  201. /****************************************************************
  202.  
  203.    gr_pixel()
  204.  
  205.    This function turns on (or off, if the color is BLACK) a single
  206.    pixel on the display.
  207.  
  208.    The argument "screen" is an integer denoted either the
  209.    visible screen (defined as GR_PRIMARY) or a hidden buffer
  210.    to which graphics output can be written (defined as
  211.    GR_HIDDEN).
  212.  
  213.    The arguments x and y specify a pixel location on the screen
  214.    in gr coordinates (see above on the coordinate system) where
  215.    the pixel is to be located, x on the horizontal axis and y
  216.    on the vertical axis.
  217.  
  218.    The argument "color" is an integer denoting a color defined
  219.    in the header "gr.h".
  220.  
  221. ****************************************************************/
  222.  
  223. gr_pixel( screen, x, y, color )
  224.    int screen;
  225.    int x, y;
  226.    int color;
  227.    
  228.          
  229. /****************************************************************
  230.  
  231.    gr_line()
  232.  
  233.    This function draws a line on the designated screen from
  234.    point x1, y1 to point x2, y2 in a specified color and
  235.    with a specified style.
  236.  
  237.    The argument "screen" is an integer denoted either the
  238.    visible screen (defined as GR_PRIMARY) or a hidden buffer
  239.    to which graphics output can be written (defined as
  240.    GR_HIDDEN).
  241.  
  242.    The arguments x1, y1, x2, and y2 specify two pixel locations
  243.    on the screen in gr coordinates (see above on the coordinate
  244.    system) denoting the source (x1, y1) and destination (x2, y2)
  245.    points for the line (x1 and x2 on the horizontal axis, and y1
  246.    and y2 on the vertical axis.
  247.  
  248.    The argument "color" is an integer denoting a color defined
  249.    in the header "gr.h".
  250.  
  251.    The argument "style" is an integer denoting a line style
  252.    defined in "gr.h" (HOLLOW, SOLID, GRID, or HATCH -- GRID
  253.    and HATCH denote dotted lines, and HOLLOW erases the area
  254.    of the line).
  255.  
  256. ****************************************************************/
  257.  
  258. gr_line( screen, x1, y1, x2, y2, color, style )
  259.    int screen;
  260.    int x1, y1, x2, y2;
  261.    int color, style;
  262.    
  263.  
  264. /****************************************************************
  265.  
  266.    gr_text()
  267.  
  268.    This function addresses text to a specified location on the
  269.    screen in specified colors.
  270.  
  271.    The argument "screen" is an integer denoted either the
  272.    visible screen (defined as GR_PRIMARY) or a hidden buffer
  273.    to which graphics output can be written (defined as
  274.    GR_HIDDEN).
  275.  
  276.    The arguments x and y specify a pixel location on the screen
  277.    in gr coordinates (see above on the coordinate system) where
  278.    the bottom left corner of the text is to be located, x on the
  279.    horizontal axis and y on the vertical axis.
  280.  
  281.    The argument "string" designates a pointer to a character
  282.    string to be written to the screen.
  283.  
  284.    The arguments "foreground" and "background" are integers
  285.    denoting text foreground and background colors as defined
  286.    in the header "gr.h".
  287.  
  288. ****************************************************************/
  289.  
  290. gr_text( screen, x, y, string, foreground, background )
  291.    int screen;
  292.    int x, y;
  293.    int foreground, background;
  294.    char *string;
  295.    
  296.  
  297. /****************************************************************
  298.  
  299.    gr_strlen()
  300.  
  301.    This function returns the length in pixels on the horizontal
  302.    (x) axis of a specified character string.
  303.  
  304.    The argument "string" designates a pointer to a character
  305.    string whose horizontal size is to be calculated.
  306.  
  307. ****************************************************************/
  308.  
  309. unsigned int
  310. gr_strlen( string )
  311.    char *string;
  312.    
  313.  
  314. /****************************************************************
  315.  
  316.    gr_rectangle()
  317.  
  318.    This function draws and possibly fills in (or blanks) a
  319.    rectangular area of the screen.
  320.  
  321.    The argument "screen" is an integer denoted either the
  322.    visible screen (defined as GR_PRIMARY) or a hidden buffer
  323.    to which graphics output can be written (defined as
  324.    GR_HIDDEN).
  325.  
  326.    The arguments x1, y1, x2, and y2 specify two pixel locations
  327.    on the screen in gr coordinates (see above on the coordinate
  328.    system) denoting the bottom left corner (x1, y1) and top right
  329.    corner (x2, y2) of the rectangle (x1 and x2 on the horizontal
  330.    axis, and y1 and y2 on the vertical axis).
  331.  
  332.    The argument "color" is an integer denoting a color defined
  333.    in the header "gr.h".
  334.  
  335.    The argument "style" is an integer denoting a fill style
  336.    defined in "gr.h" (HOLLOW, SOLID, GRID, or HATCH -- HOLLOW
  337.    means that only a perimeter is drawn; SOLID means that the
  338.    area is completely filled with the color, and GRID and HATCH
  339.    represent varying degrees of partial fill, with GRID the finer
  340.    and HATCH the rougher).
  341.  
  342. ****************************************************************/
  343.  
  344. gr_rectangle( screen, x1, y1, x2, y2, color, style )
  345.    int screen;
  346.    int x1, y1, x2, y2;
  347.    int color, style;
  348.    
  349.  
  350. /****************************************************************
  351.  
  352.    gr_circle()
  353.  
  354.    This function draws and possibly fills in (or blanks) a
  355.    circular area of the screen.
  356.  
  357.    The argument "screen" is an integer denoted either the
  358.    visible screen (defined as GR_PRIMARY) or a hidden buffer
  359.    to which graphics output can be written (defined as
  360.    GR_HIDDEN).
  361.  
  362.    The arguments x and y specify a pixel location on the screen
  363.    in gr coordinates (see above on the coordinate system) where
  364.    the center of the circle is to be located, x on the horizontal
  365.    axis and y on the vertical axis.
  366.  
  367.    The argument "radius" is an integer denoting the radius of the
  368.    circle on the y (vertical) axis. Implementers should note that
  369.    the x (horizontal) axis will have to be scaled.
  370.  
  371.    The argument "color" is an integer denoting a color defined
  372.    in the header "gr.h".
  373.  
  374.    The argument "style" is an integer denoting a fill style
  375.    defined in "gr.h" (HOLLOW, SOLID, GRID, or HATCH -- HOLLOW
  376.    means that only a perimeter is drawn; SOLID means that the
  377.    area is completely filled with the color, and GRID and HATCH
  378.    represent varying degrees of partial fill, with GRID the finer
  379.    and HATCH the rougher).
  380.  
  381. ****************************************************************/
  382.  
  383. gr_circle( screen, x, y, radius, color, style )
  384.    int screen;
  385.    int x, y, radius;
  386.    int color, style;
  387.    
  388. /****************************************************************
  389.  
  390.    gr_clip()
  391.  
  392.    If clipping is implemented (gr_clipping == TRUE), this
  393.    function turns on or off clipping for a specified area
  394.    of the screen.
  395.  
  396.    The argument "screen" is an integer denoted either the
  397.    visible screen (defined as GR_PRIMARY) or a hidden buffer
  398.    to which graphics output can be written (defined as
  399.    GR_HIDDEN).
  400.  
  401.    The argument "mode" is a boolean integer which tells whether
  402.    clipping is to be turned on (TRUE) or off (FALSE).
  403.  
  404.    The arguments x1, y1, x2, and y2 specify two pixel locations
  405.    on the screen in gr coordinates (see above on the coordinate
  406.    system) denoting the bottom left corner (x1, y1) and top right
  407.    corner (x2, y2) of the clipping rectangle (x1 and x2 on the
  408.    horizontal axis, and y1 and y2 on the vertical axis).
  409.  
  410. ****************************************************************/
  411.  
  412. gr_clip( screen, mode, x1, y1, x2, y2 )
  413.    int screen;
  414.    int mode;
  415.    int x1, y1, x2, y2;
  416.    
  417.  
  418. /****************************************************************
  419.  
  420.    gr_font()
  421.  
  422.    This function sets a font for future calls to gr_text().
  423.  
  424.    The argument "screen" is an integer denoted either the
  425.    visible screen (defined as GR_PRIMARY) or a hidden buffer
  426.    to which graphics output can be written (defined as
  427.    GR_HIDDEN).
  428.  
  429.    The argument "type" is an integer value (not currently
  430.    implemented in applications by Bywater Software) which would
  431.    denote a font type (these are defined in "gr.h" as F_DEFAULT,
  432.    F_ROMAN, F_ITALIC, and F_GOTHIC). Don't worry about it.
  433.  
  434.    The argument "rq_height" is an integer value denoting the
  435.    requested height of the new font in pixels. The function should
  436.    set the closest available height and then denote the size of
  437.    the new font in the fysize variable in the gr_display structure.
  438.  
  439. ****************************************************************/
  440.  
  441. gr_font( screen, type, rq_height )
  442.    int screen;
  443.    int type, rq_height;
  444.    
  445.  
  446. /****************************************************************
  447.  
  448.    gr_blit()
  449.  
  450.    This function "blits" (copies) a rectangular area of the screen
  451.    from GR_PRIMARY to GR_HIDDEN or vice versa (if blitting is
  452.    implemented, i.e., gr_blitting == TRUE).
  453.  
  454.    The arguments "src" and "dst" are integers denoting either the
  455.    visible screen (defined as GR_PRIMARY) or a hidden buffer
  456.    to which graphics output can be written (defined as
  457.    GR_HIDDEN). Obviously, one should be set to GR_PRIMARY and
  458.    one to GR_HIDDEN. "src" denotes the source of the blit, and
  459.    "dst" the destination.
  460.  
  461.    The arguments x1, y1, x2, and y2 specify two pixel locations
  462.    on the screen in gr coordinates (see above on the coordinate
  463.    system) denoting the bottom left corner (x1, y1) and top right
  464.    corner (x2, y2) of the area to be blitted (x1 and x2 on the
  465.    horizontal axis, and y1 and y2 on the vertical axis).
  466.  
  467. ****************************************************************/
  468.  
  469. gr_blit( src, dst, x1, y1, x2, y2 )
  470.    int src, dst;
  471.    int x1, y1, x2, y2;
  472.    
  473.  
  474. /****************************************************************
  475.  
  476.    gr_imsave()
  477.  
  478.    This function either saves a rectangluar area of the screen to
  479.    a memory buffer (mode == TRUE), or restores a rectangular screen
  480.    area from the buffer (mode == FALSE). It should free existing memory
  481.    when mode == FALSE (thus, the area cannot be restored more than once).
  482.  
  483.    The argument "screen" is an integer denoted either the
  484.    visible screen (defined as GR_PRIMARY) or a hidden buffer
  485.    to which graphics output can be written (defined as
  486.    GR_HIDDEN).
  487.  
  488.    The arguments x1, y1, x2, and y2 specify two pixel locations
  489.    on the screen in gr coordinates (see above on the coordinate
  490.    system) denoting the bottom left corner (x1, y1) and top right
  491.    corner (x2, y2) of the rectangular area to be saved (x1 and x2
  492.    on the horizontal axis, and y1 and y2 on the vertical axis).
  493.  
  494.    The argument "image" is a pointer to an integer that will denote
  495.    the specific image stored (mode = FALSE) or that will be set to a 
  496.    new unique number for the image (mode = TRUE).
  497.  
  498. ****************************************************************/
  499.  
  500. gr_imsave( screen, mode, x1, y1, x2, y2, image )
  501.    int screen; 
  502.    int mode, x1, y1, x2, y2;
  503.    int *image;
  504.    
  505.  
  506. /****************************************************************
  507.  
  508.    gr_imfree()
  509.  
  510.    This function frees emory allocated by a call to gr_imsave().
  511.  
  512. ****************************************************************/
  513.  
  514. gr_imfree( image )
  515.    int image;
  516.    
  517.  
  518. /****************************************************************
  519.  
  520.    gr_mouse()
  521.  
  522.    This function either tells if a mouse button has been pushed
  523.    (mode == SAMPLE or STATUS) or waits for a button to be pushed
  524.    (mode == WAIT).
  525.  
  526.    The arguments x and y are integer pointers to be filled with a
  527.    screen location in gr coordinates (see above on the coordinate
  528.    system) where the mouse is currently located, x on the horizontal
  529.    axis and y on the vertical axis.
  530.  
  531.    The argument "buttons" is an integer pointer which some great
  532.    day will be used to specify which of the mouse buttons has been
  533.    pushed but it hasn't been used yet in any Bywater applications
  534.    so don't worry about it.
  535.  
  536. ****************************************************************/
  537.  
  538. gr_mouse( mode, x, y, buttons )
  539.    int mode;
  540.    int *x, *y;
  541.    int *buttons;
  542.    
  543.  
  544. REFERENCE FOR KB (KEYBOARD) SYSTEM:
  545. ----------------------------------
  546.  
  547. #define KB_ALT          0x500
  548.  
  549. #define KB_UP           0x201
  550. #define KB_DOWN         0x202
  551. #define KB_LEFT         0x203
  552. #define KB_RIGHT        0x204
  553. #define KB_P_UP         0x207
  554. #define KB_P_DOWN       0x208
  555. #define KB_HOME         0x209
  556. #define KB_END          0x20a
  557. #define KB_INSERT       0x211
  558. #define KB_DELETE       0x212
  559.  
  560. #define KB_FK0          0x220
  561. #define KB_FK1          0x221
  562. #define KB_FK2          0x222
  563. #define KB_FK3          0x223
  564. #define KB_FK4          0x224
  565. #define KB_FK5          0x225
  566. #define KB_FK6          0x226
  567. #define KB_FK7          0x227
  568. #define KB_FK8          0x228
  569. #define KB_FK9          0x229
  570.  
  571. /*************************************************************************
  572.  
  573.     FUNCTION:       kb_init()
  574.  
  575.     DESCRIPTION:    This function should perform any initialization
  576.             necessary for the keyboard system.
  577.  
  578.     INPUT:          none.
  579.  
  580.     RETURNS:        none.
  581.  
  582. **************************************************************************/
  583.  
  584. kb_init()
  585.     
  586.  
  587. /*************************************************************************
  588.  
  589.     FUNCTION:       kb_deinit()
  590.  
  591.     DESCRIPTION:    This function should perform any necessary
  592.             deinitialization, that is, return the keyboard
  593.             to its default state when a Simple Software
  594.             program is to be exited.
  595.  
  596.     INPUT:          none.
  597.  
  598.     RETURNS:        none.
  599.  
  600. **************************************************************************/
  601.  
  602. kb_deinit()
  603.     
  604.  
  605. /*************************************************************************
  606.  
  607.     FUNCTION:       kb_rxstat()
  608.  
  609.     DESCRIPTION:    This function determines whether a character is
  610.             ready from the console.  The function is used
  611.             especially in telecommunications programs,
  612.             where it is necessary to poll the keyboard
  613.             without locking up the program waiting for a
  614.             response.
  615.  
  616.     INPUT:          none.
  617.  
  618.     RETURNS:        The function returns 0 if no character is
  619.             available and 1 if a character is available.
  620.  
  621. **************************************************************************/
  622.  
  623. kb_rxstat()
  624.     
  625.  
  626. /*************************************************************************
  627.  
  628.     FUNCTION:       kb_rx()
  629.  
  630.     DESCRIPTION:    This function returns a single character from
  631.             the keyboard.  If a character is not available
  632.             it waits.  The function should be able to
  633.             recognize any special keys, and return the
  634.             appropriate Simple Software KB conventions
  635.             designated for them.
  636.  
  637.     INPUT:          none.
  638.  
  639.     RETURNS:        The function returns the ASCII code for the
  640.             key pressed, or the Simple Software KB convention
  641.             (see kb.h) for a function or other special key.
  642.  
  643. **************************************************************************/
  644.  
  645. kb_rx()
  646.      
  647.  
  648. REFERENCE FOR DR (DIRECTORY) SYSTEM:
  649. -----------------------------------
  650.  
  651. struct dir_ent
  652.     {
  653.     char     filename[ MAX_PATHLENGTH ];
  654.     char    pathname[ MAX_PATHLENGTH ];
  655.     int     type;
  656.     long    size;
  657.     };
  658.  
  659. extern    int    dr_fs;
  660. extern    char    dr_all[ MAX_PATHLENGTH ];
  661.  
  662. /*************************************************************************
  663.  
  664.    dr_first()
  665.  
  666.    This function returns the first instance of a file matching an
  667.    ambiguous file specifier (TRUE) or FALSE if no matches are found.
  668.  
  669.    The argument "findb" is a pointer to a character string which
  670.    is the ambiguous file specifier.
  671.  
  672.    The argument "retb" is a pointer to a character buffer where
  673.    the returned value (if TRUE) will be written.
  674.  
  675. **************************************************************************/
  676.  
  677. dr_first( findb, retb )
  678.     char findb[];
  679.     struct dir_ent *retb;
  680.     
  681.  
  682. /*************************************************************************
  683.  
  684.    dr_next()
  685.  
  686.    This function returns the next instance of a file matching the
  687.    ambiguous file specifier previously supplied to dr_first(TRUE),
  688.    or FALSE if no further matches are found.
  689.  
  690.    The argument "retb" is a pointer to a character buffer where
  691.    the returned value (if TRUE) will be written.
  692.  
  693. **************************************************************************/
  694.  
  695. dr_next( retb )
  696.     struct dir_ent *retb;
  697.     
  698.  
  699. REFERENCE FOR TW (TEXT WINDOW) SYSTEM:
  700. -------------------------------------
  701.  
  702. struct tw_struct
  703.    {
  704.    int          x1;                     /* left side in graphics coords */
  705.    int          y1;                     /* bottom in graphics coords */
  706.    int          x2;                     /* right side in graphics coords */
  707.    int          y2;                     /* top in graphics coords */
  708.    int          fxsize;                 /* font size graphics coords */
  709.    int          fysize;                 /* font size graphics coords */
  710.    int          lines;                  /* number of text lines */
  711.    int          columns;                /* number of text columns */
  712.    }
  713.  
  714.  
  715. /*****************************************************************
  716.  
  717.     tw_init()
  718.  
  719.     This function opens a text window and performs necessary
  720.     initializations.  
  721.  
  722.     rq_x1, rq_y1, rq_x2, and rq_y2 specify coordinates for 
  723.     the requested text window.  
  724.  
  725.     rq_lines and rq_cols specify the requested number of text
  726.     lines and columns requested.
  727.  
  728.     min_x1, min_y1, min_x2, and min_y2 specify rectangluar
  729.     bounds that may not be transgressed in assigning the
  730.     new text window (i.e., should not go farther left than
  731.     x1, should not go farther down than y1, should not go
  732.     farther right than x2, and should not go farther up than
  733.     y2).
  734.  
  735.     The function returns NULL if unsuccessful, or a pointer
  736.     to a tw_struct structure, which will include the 
  737.     coordinates actually assigned to the new window.
  738.  
  739. *****************************************************************/
  740.  
  741. struct tw_struct *
  742. tw_init( rq_x1, rq_y2, rq_lines, rq_cols, min_x1, min_y1, max_x2, max_y2 )
  743.    int rq_x1;                   /* requested x1 (left, graphics) position */
  744.    int rq_y2;                   /* requested y2 (top,  graphics) position */
  745.    int rq_lines;                /* requested text lines */
  746.    int rq_cols;                 /* requested text columns */
  747.    int min_x1;                  /* leftmost   allowable position */
  748.    int min_y1;                  /* bottommost allowable position */
  749.    int max_x2;                  /* rightmost  allowable position */
  750.    int max_y2;                  /* topmost    allowable position */
  751.    
  752.  
  753. /*****************************************************************
  754.  
  755.     tw_deinit()
  756.  
  757.     This function performs any necessary deinitialization
  758.     of a text window.
  759.  
  760. *****************************************************************/
  761.  
  762. tw_deinit( tw )
  763.    struct tw_struct *tw;
  764.    
  765.  
  766. /*****************************************************************
  767.  
  768.     tw_outc()
  769.  
  770.     This function outputs a single character (c) to the
  771.     currently selected text window at the current position
  772.     and in the current color.
  773.  
  774. *****************************************************************/
  775.  
  776. tw_outc( c )
  777.    int c;
  778.    
  779.  
  780. /*****************************************************************
  781.  
  782.     tw_outs()
  783.  
  784.     This function outputs a line of text to the currently
  785.     selected text window at the position specified by 
  786.     line and column, with the color specified.
  787.  
  788. *****************************************************************/
  789.  
  790. tw_outs( s, line, column, color )
  791.    char *s;
  792.    int line, column, color;
  793.    
  794.  
  795. /*****************************************************************
  796.  
  797.     tw_adr()
  798.  
  799.     This function addresses the cursor in the currently
  800.     selected text window to a specified line and column.
  801.  
  802. *****************************************************************/
  803.  
  804. tw_adr( line, column )
  805.    int line, column;
  806.    
  807.  
  808. /*****************************************************************
  809.  
  810.     tw_cursor()
  811.  
  812.     This function turns on or off the cursor in the 
  813.     currently selected text window (1 = ON, 0 = OFF).
  814.  
  815. *****************************************************************/
  816.  
  817. tw_cursor( action )
  818.   int action;
  819.   
  820.  
  821. /*****************************************************************
  822.  
  823.     tw_cleol()
  824.  
  825.     This function clears the line of text in the currently
  826.     selected text window from the cursor position to the
  827.     end of the line.
  828.  
  829. *****************************************************************/
  830.  
  831. tw_cleol( line, column )
  832.    int line, column;
  833.    
  834.  
  835. REFERENCE FOR UI (USER INTERFACE) SYSTEM:
  836. ----------------------------------------
  837.  
  838. struct   uiwindow
  839.    {
  840.    int     x1;             /* left of whole area           */
  841.    int     y1;             /* bottom of whole area         */
  842.    int     x2;             /* right of whole area          */
  843.    int     y2;             /* top of whole area            */
  844.    int     t_flag;         /* is there a title ?           */
  845.    int     t_bcolor;       /* title background color       */
  846.    int     t_tcolor;       /* title text color             */
  847.    int     tbar_x1;        /* left of title bar            */
  848.    int     tbar_y1;        /* bottom of title bar          */
  849.    int     tbar_x2;        /* right of title bar           */
  850.    int     tbar_y2;        /* top of title bar             */
  851.    int     ti_x1;          /* left side of title area    */
  852.    int     ti_y1;          /* bottom of title area       */
  853.    int     ti_x2;          /* right side of title area   */
  854.    int     ti_y2;          /* top of title area          */
  855.    int     s_flag;         /* is there a shadow?           */
  856.    int     s_color;        /* shadow color                 */
  857.    int     b_flag;         /* is there a border ?          */
  858.    int     b_color;        /* border color                 */
  859.    int     m_color;        /* main area color              */
  860.    int     m_style;        /* main area fill style         */
  861.    int     buttons;        /* buttons selected             */
  862.    int     bt_x1;          /* left side of close button    */
  863.    int     bt_y1;          /* bottom of close button       */
  864.    int     bt_x2;          /* right side of close button   */
  865.    int     bt_y2;          /* top of close button          */
  866.    int     re_x1;          /* left side of resize button   */
  867.    int     re_y1;          /* bottom of resize button      */
  868.    int     re_x2;          /* right side of resize button  */
  869.    int     re_y2;          /* top of resize button         */
  870.    int     mv_x1;          /* left side of move button     */
  871.    int     mv_y1;          /* bottom of move button        */
  872.    int     mv_x2;          /* right side of move button    */
  873.    int     mv_y2;          /* top of move button           */
  874.    int     u_x1;           /* left of usable space         */
  875.    int     u_y1;           /* bottom of usable space       */
  876.    int     u_x2;           /* right of usable space        */
  877.    int     u_y2;           /* top of usable space          */
  878.    };
  879.  
  880. struct  menu_box
  881.    {
  882.    struct  uiwindow *window;       /* uiwindow for menu/icon box   */
  883.    int     type;                   /* type of menu                 */
  884.    char    **d_titles;             /* array of titles              */
  885.    struct  dir_ent **d_entries;    /* array of directory entries   */
  886.    int     max_entries;            /* max items in each array      */
  887.    int     is_drawn;               /* is menu/icon box drawn?      */
  888.    int     save_fysize;            /* save font y size             */
  889.    int     save_font;              /* save font type               */
  890.    int     xsize;                  /* x size of single icon space  */
  891.    int     ysize;                  /* y size of single icon space  */
  892.    int     x_items;                /* number of icons on x axis    */
  893.    int     y_items;                /* number of icons on y axis    */
  894.    int     x_logical;              /* logical items on x axis      */
  895.    int     y_logical;              /* logical items on y axis      */
  896.    int     x_pos;                  /* current position, x axis     */
  897.    int     y_pos;                  /* current position, y axis     */
  898.    int     current;                /* currently selected item      */
  899.    int     x_start;                /* starting position for x axis */
  900.    int     y_start;                /* starting position for y axis */
  901.    int     fore;                   /* foreground color             */
  902.    int     back;                   /* background color             */
  903.    int     high;                   /* highlight color              */
  904.    int     number;                 /* total number of icons/menu items */
  905.    int     i_x1;                   /* icon area, left              */
  906.    int     i_y1;                   /* icon area, bottom            */
  907.    int     i_x2;                   /* icon area, right             */
  908.    int     i_y2;                   /* icon area, top               */
  909.    int     vs_x1;                  /* vertical slide, left         */
  910.    int     vs_y1;                  /* vertical slide, bottom       */
  911.    int     vs_x2;                  /* vertical slide, right        */
  912.    int     vs_y2;                  /* vertical slide, top          */
  913.    int     ve_y1;                  /* vertical elevator, bottom    */
  914.    int     ve_y2;                  /* vertical elevator, top       */
  915.    int     hs_x1;                  /* horizontal slide, left       */
  916.    int     hs_y1;                  /* horizontal slide, bottom     */
  917.    int     hs_x2;                  /* horizontal slide, right      */
  918.    int     hs_y2;                  /* horizontal slide, top        */
  919.    int     he_x1;                  /* horizontal elevator, left    */
  920.    int     he_x2;                  /* horizontal elevator, right   */
  921.    int     vel_x1;                 /* vertical elevator left       */
  922.    int     vel_y1;                 /* vertical elevator bottom     */
  923.    int     vel_x2;                 /* vertical elevator right      */
  924.    int     vel_y2;                 /* vertical elevator top        */
  925.    int     vel_inc;                /* vertical elevator increment  */
  926.    int     hel_x1;                 /* horizontal elevator left     */
  927.    int     hel_y1;                 /* horizontal elevator bottom   */
  928.    int     hel_x2;                 /* horizontal elevator right    */
  929.    int     hel_y2;                 /* horizontal elevator top      */
  930.    int     hel_inc;                /* horizontal elevator increment */
  931.    };
  932.  
  933. /*****************************************************************
  934.  
  935.  
  936.  
  937. *****************************************************************/
  938.  
  939. struct pbm_struct
  940.    {
  941.    int xsize;
  942.    int ysize;
  943.    char *image;
  944.    };
  945.  
  946. /*****************************************************************
  947.  
  948.  
  949.  
  950. *****************************************************************/
  951.  
  952. struct ui_twstruct
  953.    {
  954.    struct tw_struct *tw;
  955.    struct uiwindow  *uiw;
  956.    };
  957.  
  958. /*****************************************************************
  959.  
  960.  
  961.  
  962. *****************************************************************/
  963.  
  964. ui_init()
  965.    
  966.  
  967. /*****************************************************************
  968.  
  969.  
  970.  
  971. *****************************************************************/
  972.  
  973. ui_setscreen( screen )
  974.    int screen;
  975.    
  976.  
  977. /*****************************************************************
  978.  
  979.  
  980.  
  981. *****************************************************************/
  982.  
  983. ui_push()
  984.    
  985.  
  986. /*****************************************************************
  987.  
  988.  
  989.  
  990. *****************************************************************/
  991.  
  992. ui_pop()
  993.    
  994. /*****************************************************************
  995.  
  996.  
  997.  
  998. *****************************************************************/
  999.  
  1000. struct uiwindow *
  1001. ui_window( x1, y1, x2, y2, t_flag, t_bcolor, t_tcolor, t_text,
  1002.    b_flag, b_color,
  1003.    s_flag, s_color, m_color, m_style, buttons )
  1004.    int x1, y1, x2, y2;          /* coordinates of whole area    */
  1005.    int t_flag;                  /* title flag         */
  1006.    int t_bcolor, t_tcolor;      /* title background & text colors */
  1007.    char *t_text;                /* text of title      */
  1008.    int b_flag, b_color;         /* border flag, color      */
  1009.    int s_flag, s_color;         /* shadow flag, color      */
  1010.    int m_color, m_style;        /* color & style for main box   */
  1011.    int buttons;                 /* buttons */
  1012.    
  1013.  
  1014. /*****************************************************************
  1015.  
  1016.  
  1017.  
  1018. *****************************************************************/
  1019.  
  1020. ui_rewindow( window, newtitle )
  1021.    struct uiwindow *window;
  1022.    char *newtitle;
  1023.    
  1024.  
  1025. /*****************************************************************
  1026.  
  1027.  
  1028.  
  1029. *****************************************************************/
  1030.  
  1031. ui_fbox( x1, y1, x2, y2, color, style )
  1032.    int x1, y1, x2, y2, color, style;
  1033.    
  1034.  
  1035. /*****************************************************************
  1036.  
  1037.  
  1038.  
  1039. *****************************************************************/
  1040.  
  1041. ui_hbox( x1, y1, x2, y2, color )
  1042.    int x1, y1, x2, y2, color;
  1043.    
  1044.  
  1045. /*****************************************************************
  1046.  
  1047.  
  1048.  
  1049. *****************************************************************/
  1050.  
  1051. ui_wtitle( window, buffer )
  1052.    struct uiwindow *window;
  1053.    char *buffer;
  1054.    
  1055. /*****************************************************************
  1056.  
  1057.  
  1058.  
  1059. *****************************************************************/
  1060.  
  1061. ui_str( x1, y1, x2, background, foreground, buffer )
  1062.    int x1, y1, x2, background, foreground;
  1063.    char *buffer;
  1064.    
  1065.  
  1066. /*****************************************************************
  1067.  
  1068.  
  1069.  
  1070. *****************************************************************/
  1071.  
  1072. ui_text( x1, y1, x2, y2, maxlines, background, foreground, main_buffer )
  1073.    int x1, y1, x2, y2;          /* Coordinates of box */
  1074.    int maxlines;                /* Maximum lines to be used */
  1075.    int background;              /* Background color */
  1076.    int foreground;              /* Foreground color */
  1077.    char *main_buffer;           /* Text buffer */
  1078.    
  1079. /*****************************************************************
  1080.  
  1081.  
  1082.  
  1083. *****************************************************************/
  1084.  
  1085. ui_wait()
  1086.     
  1087.  
  1088. /*****************************************************************
  1089.  
  1090.  
  1091.  
  1092. *****************************************************************/
  1093.  
  1094. ui_getch()
  1095.     
  1096.  
  1097. /*****************************************************************
  1098.  
  1099.  
  1100.  
  1101. *****************************************************************/
  1102.  
  1103. ui_gets( window, x, y, maxlength, buffer, display, foreground, background  )
  1104.     struct gr_window *window;
  1105.     int x, y, maxlength, display, foreground, background;
  1106.     char *buffer;
  1107.     
  1108. /*****************************************************************
  1109.  
  1110.  
  1111.  
  1112. *****************************************************************/
  1113.  
  1114. ui_dial( x1, y1, x2, y2, background, foreground, marker_color, shadow,
  1115.    title, text, prompt, buffer, i_window )
  1116.    int x1, y1, x2, y2, background, foreground, shadow, marker_color;
  1117.    char *title, *text, *prompt, *buffer;
  1118.    struct uiwindow **i_window;
  1119.    
  1120.  
  1121. /*****************************************************************
  1122.  
  1123.  
  1124.  
  1125. *****************************************************************/
  1126.  
  1127. ui_yn( x1, y1, x2, y2, background, foreground, marker_color, shadow,
  1128.    text, mes0, mes1, i_window )
  1129.    int x1, y1, x2, y2, background, foreground, shadow, marker_color;
  1130.    char *text, *mes0, *mes1;
  1131.    struct uiwindow **i_window;
  1132.    
  1133.  
  1134. /*****************************************************************
  1135.  
  1136.  
  1137.  
  1138. *****************************************************************/
  1139.  
  1140. ui_alarm( x1, y1, x2, y2, background, foreground, marker_color, shadow,
  1141.    text, prompt, i_window )
  1142.    int x1, y1, x2, y2, background, foreground, shadow, marker_color;
  1143.    char *text, *prompt;
  1144.    struct uiwindow **i_window;
  1145.    
  1146.  
  1147. /*****************************************************************
  1148.  
  1149.  
  1150.  
  1151. *****************************************************************/
  1152.  
  1153. ui_disp( x1, y1, x2, y2, background, foreground, shadow, title, text,
  1154.    i_window )
  1155.    int x1, y1, x2, y2, background, foreground, shadow;
  1156.    char *title, *text;
  1157.    struct uiwindow **i_window;
  1158.    
  1159.  
  1160. /****************************************************************
  1161.  
  1162.    ui_ftext()   File selection -- text based
  1163.  
  1164. ****************************************************************/
  1165.  
  1166. ui_ftext( x1, y1, x2, y2, specifier, title, m_box,
  1167.    d_titles, d_entries, max_entries,
  1168.    background, foreground, highlight )
  1169.    int x1, y1, x2, y2, background, foreground, highlight, max_entries;
  1170.    struct menu_box *m_box;
  1171.    char *specifier, *title;
  1172.    char **d_titles;
  1173.    struct dir_ent **d_entries;
  1174.    
  1175.  
  1176. /****************************************************************
  1177.  
  1178.    ui_list()   Scrolling list (menu)
  1179.  
  1180. ****************************************************************/
  1181.  
  1182. ui_list( type, x1, y1, x2, y2, title, number, titles,
  1183.    foreground, background, highlight, m_box )
  1184.    int type, x1, y1, x2, y2, foreground, background,
  1185.       highlight, number;
  1186.    char *title;
  1187.    char **titles;
  1188.    struct menu_box *m_box;
  1189.    
  1190.  
  1191. /****************************************************************
  1192.  
  1193.     uil_draw() - draw a list box
  1194.  
  1195. ****************************************************************/
  1196.  
  1197. uil_draw( type, x1, y1, x2, y2, title, number, titles,
  1198.    foreground, background, highlight, m_box )
  1199.    int type, x1, y1, x2, y2, foreground, background,
  1200.       highlight, number;
  1201.    char *title;
  1202.    char **titles;
  1203.    struct menu_box *m_box;
  1204.    
  1205.  
  1206. /****************************************************************
  1207.  
  1208.    uil_activate()   Activate a list box
  1209.  
  1210. ****************************************************************/
  1211.  
  1212. uil_activate( m_box, type, item )
  1213.    struct menu_box *m_box;
  1214.    int type, item;
  1215.    
  1216.  
  1217. /****************************************************************
  1218.  
  1219.    uil_deactivate()   Deactivate a list menu box
  1220.  
  1221. ****************************************************************/
  1222.  
  1223. uil_deactivate( m_box, type )
  1224.    struct menu_box *m_box;
  1225.    int type;
  1226.    
  1227.  
  1228. /****************************************************************
  1229.  
  1230.    uil_event()   Query if an event affects a list box
  1231.  
  1232. ****************************************************************/
  1233.  
  1234. uil_event( m_box, key, mo_xsrc, mo_ysrc, mo_xdest, mo_ydest, type, item )
  1235.    struct menu_box *m_box;
  1236.    int key, mo_xsrc, mo_ysrc, mo_xdest, mo_ydest, type;
  1237.    int *item;
  1238.    
  1239. /****************************************************************
  1240.  
  1241.    ui_event()   Query if keyboard or mouse actions affect
  1242.                  a list or icon menu box
  1243.  
  1244. ****************************************************************/
  1245.  
  1246. ui_event( m_box, key, mo_xsrc, mo_ysrc, mo_xdest, mo_ydest,
  1247.    how_far, x_sel, y_sel )
  1248.    struct menu_box *m_box;
  1249.    int key, mo_xsrc, mo_ysrc, mo_xdest, mo_ydest;
  1250.    int *how_far, *x_sel, *y_sel;
  1251.    
  1252.  
  1253. /****************************************************************
  1254.  
  1255.    uil_bounds()  See if x and y are within bounds of x1, y1, x2, y2
  1256.  
  1257. ****************************************************************/
  1258.  
  1259. uil_bounds( x, y, x1, y1, x2, y2 )
  1260.    int x, y, x1, y1, x2, y2;
  1261.    
  1262.  
  1263. /****************************************************************
  1264.  
  1265.    ui_ficon()   File selection -- icon-based
  1266.  
  1267. ****************************************************************/
  1268.  
  1269. ui_ficon( x1, y1, x2, y2, specifier, title, m_box,
  1270.    d_entries, max_entries,
  1271.    background, foreground, highlight )
  1272.    int x1, y1, x2, y2, background, foreground, highlight, max_entries;
  1273.    struct menu_box *m_box;
  1274.    char *specifier, *title;
  1275.    struct dir_ent **d_entries;
  1276.    
  1277.  
  1278. /****************************************************************
  1279.  
  1280.     uii_draw()      - draw file selection icon area
  1281.  
  1282. ****************************************************************/
  1283.  
  1284. uii_draw( x1, y1, x2, y2, specifier, title, m_box,
  1285.    d_entries, max_entries,
  1286.    background, foreground, highlight )
  1287.    int x1, y1, x2, y2, background, foreground, highlight, max_entries;
  1288.    struct menu_box *m_box;
  1289.    char *specifier, *title;
  1290.    struct dir_ent **d_entries;
  1291.    
  1292.  
  1293. /****************************************************************
  1294.  
  1295.    uii_activate()   Activate an icon menu box
  1296.  
  1297. ****************************************************************/
  1298.  
  1299. uii_activate( m_box, item )
  1300.    struct menu_box *m_box;
  1301.    int item;
  1302.    
  1303.  
  1304. /****************************************************************
  1305.  
  1306.    uii_deactivate()   Deactivate an icon menu box
  1307.  
  1308. ****************************************************************/
  1309.  
  1310. uii_deactivate( m_box )
  1311.    struct menu_box *m_box;
  1312.    
  1313.  
  1314. /****************************************************************
  1315.  
  1316.    uii_event()   Query if keyboard or mouse actions affect an icon
  1317.                 menu box
  1318.  
  1319. ****************************************************************/
  1320.  
  1321. uii_event( m_box, key, mo_xsrc, mo_ysrc, mo_xdest, mo_ydest, item )
  1322.    struct menu_box *m_box;
  1323.    int key, mo_xsrc, mo_ysrc, mo_xdest, mo_ydest;
  1324.    int *item;
  1325.    
  1326.  
  1327. /****************************************************************
  1328.  
  1329.    uii_source()   Query if keyboard or mouse actions indicate a
  1330.           source within a menu box
  1331.  
  1332. ****************************************************************/
  1333.  
  1334. uii_source( m_box, key, mo_xsrc, mo_ysrc, mo_xdest, mo_ydest, item )
  1335.    struct menu_box *m_box;
  1336.    int key, mo_xsrc, mo_ysrc, mo_xdest, mo_ydest;
  1337.    int *item;
  1338.    
  1339. /*****************************************************************
  1340.  
  1341.  
  1342.  
  1343. *****************************************************************/
  1344.  
  1345. ui_pbmread( file, pmstruct, foreground, background )
  1346.    char *file;
  1347.    struct pbm_struct *pmstruct;
  1348.    int foreground, background;
  1349.    
  1350.  
  1351. /*****************************************************************
  1352.  
  1353.  
  1354.  
  1355. *****************************************************************/
  1356.  
  1357. ui_pbmshow( screen, x, y, pmstruct )
  1358.    int screen;
  1359.    int x, y;
  1360.    struct pbm_struct *pmstruct;
  1361.    
  1362.  
  1363. /*****************************************************************
  1364.  
  1365.  
  1366.  
  1367. *****************************************************************/
  1368.  
  1369. ui_pbmcenter( screen, x1, y1, x2, y2, pmstruct )
  1370.    int screen;
  1371.    int x1, y1, x2, y2;
  1372.    struct pbm_struct *pmstruct;
  1373.    
  1374.  
  1375. /*****************************************************************
  1376.  
  1377.  
  1378.  
  1379. *****************************************************************/
  1380.  
  1381. ui_pbmtile( screen, x1, y1, x2, y2, pmstruct )
  1382.    int screen;
  1383.    int x1, y1, x2, y2;
  1384.    struct pbm_struct *pmstruct;
  1385.    
  1386. /*****************************************************************
  1387.  
  1388.  
  1389.  
  1390. *****************************************************************/
  1391.  
  1392. ui_clinit( x, y, fore, back )
  1393.     int x, y, fore, back;
  1394.     
  1395.  
  1396. /*****************************************************************
  1397.  
  1398.  
  1399.  
  1400. *****************************************************************/
  1401.  
  1402. ui_clock()
  1403.     
  1404.  
  1405. /*****************************************************************
  1406.  
  1407.  
  1408.  
  1409. *****************************************************************/
  1410.  
  1411. ui_clforce()
  1412.     
  1413. /*****************************************************************
  1414.  
  1415.  
  1416.  
  1417. *****************************************************************/
  1418.  
  1419. ui_rband( mode, x1, y1, x2, y2 )
  1420.    int mode;
  1421.    int *x1, *y1, *x2, *y2;
  1422.    
  1423. /*****************************************************************
  1424.  
  1425.  
  1426.  
  1427. *****************************************************************/
  1428.  
  1429. struct ui_twstruct *
  1430. ui_twinit( title, rq_x1, rq_y2, rq_lines, rq_cols,
  1431.        min_x1, min_y1, max_x2, max_y2 )
  1432.    char *title;                 /* ttle for window */
  1433.    int rq_x1;                   /* requested x1 (left, graphics) position */
  1434.    int rq_y2;                   /* requested y2 (top,  graphics) position */
  1435.    int rq_lines;                /* requested text lines */
  1436.    int rq_cols;                 /* requested text columns */
  1437.    int min_x1;                  /* leftmost   allowable position */
  1438.    int min_y1;                  /* bottommost allowable position */
  1439.    int max_x2;                  /* rightmost  allowable position */
  1440.    int max_y2;                  /* topmost    allowable position */
  1441.    
  1442.  
  1443. /*****************************************************************
  1444.  
  1445.  
  1446.  
  1447. *****************************************************************/
  1448.  
  1449. ui_twdeinit()
  1450.    
  1451.  
  1452.